package com.whty.cms.filewps.common.aspect;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

//@Component
public class ChannelFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }
 
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
    	ServletRequest requestWrapper = null;
        if(servletRequest instanceof HttpServletRequest) {
        	String uri = ((HttpServletRequest) servletRequest).getRequestURI();
        	if(uri.indexOf("uploadFile")>-1) {
        		
        	}else {
        		requestWrapper = new RequestWrapper((HttpServletRequest) servletRequest);
        	}
        }
        if(requestWrapper == null) {
            filterChain.doFilter(servletRequest, servletResponse);
        } else {
            filterChain.doFilter(requestWrapper, servletResponse);
        }
    }
 
    @Override
    public void destroy() {

    }
}